function negLL = ptm7(params,wdata)
% params(1): lottery weighting for buyer
% params(2): decisiveness
% params(3): response bias for buyer
% params(4): lottery weighting for seller
% params(5): response bias for seller
% 0: fixed utility for buyer
% 0: fixed utility for seller

priceutil = wdata.Price;
lotteryutil = (wdata.Role==1).* (0.5.*params(1).*wdata.Lottery) + ...
              (wdata.Role==2).* (0.5.*params(4).*wdata.Lottery);
pending = (wdata.Role==1).*((params(3)>=0).*((1-params(3))./(1+exp(-params(2)*(lotteryutil-priceutil) + 0))+ params(3)) + (1-(params(3)>=0)).*(1+params(3))./(1+exp(-params(2)*(lotteryutil-priceutil) + 0))) + ...
          (wdata.Role==2).*((params(5)>=0).*((1-params(5))./(1+exp(-params(2)*(lotteryutil-priceutil) + 0))+ params(5)) + (1-(params(5)>=0)).*(1+params(5))./(1+exp(-params(2)*(lotteryutil-priceutil) + 0))) ;
% pending(pending==0) = eps; 
negLL = - sum( wdata.Ending.*log(pending) + (1-wdata.Ending).*log(1-pending) );

end